<style scoped>
.layout {
  /* border: 1px solid #d7dde4; */
  background: #f5f7f9;
  position: relative;
  /* border-radius: 4px; */
  overflow: hidden;
  min-height: 100vh;
}
.layout-header-bar {
  background: #fff;
  /* box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); */
}
.layout-logo-left {
  width: 90%;
  height: 30px;
  background: #5b6270;
  border-radius: 3px;
  margin: 15px auto;
}
.menu-icon {
  transition: all 0.3s;
}
.rotate-icon {
  transform: rotate(-90deg);
}
.menu-item span {
  display: inline-block;
  overflow: hidden;
  width: 69px;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  transition: width 0.2s ease 0.2s;
}
.menu-item i {
  transform: translateX(0px);
  transition: font-size 0.2s ease, transform 0.2s ease;
  vertical-align: middle;
  font-size: 16px;
}
.collapsed-menu span {
  width: 0px;
  transition: width 0.2s ease;
}
.collapsed-menu i {
  transform: translateX(5px);
  transition: font-size 0.2s ease 0.2s, transform 0.2s ease 0.2s;
  vertical-align: middle;
  font-size: 22px;
}
</style>
<template>
    <div class="layout">
        <Layout>
            <Sider ref="side1" hide-trigger collapsible :collapsed-width="78" v-model="isCollapsed" width="250px">
                <div class="logo" style="text-align:center">
                  <img v-if="!isCollapsed" src="../assets/logo_2.png" style="width:80%;margin-top:2vh">
                  <img v-else src="../assets/logo.png" style="width:80%; margin-top:2vh" >
                </div>
                <Menu active-name="home" theme="dark" width="auto" :class="menuitemClasses" style="margin-top:1vh">
                    <MenuItem name="home" to='/'>
                        <Icon type="ios-navigate"></Icon>
                        <span>网站概览</span>
                    </MenuItem>
                    <MenuItem name="user" to='/user'>
                        <Icon type="ios-person"></Icon>
                        <span>用户管理</span>
                    </MenuItem>
                    <MenuItem name="question"  to='/question'>
                        <Icon type="ios-settings"></Icon>
                        <span>题库管理</span>
                    </MenuItem>
                </Menu>
            </Sider>
            <Layout>
                <Header :style="{padding: 0, height:'6vh'}" class="layout-header-bar">
                    <Icon
                        @click.native="collapsedSider"
                        :class="rotateIcon"
                        :style="{margin: '0 1vh'}"
                        type="md-menu"
                        size="24"
                    ></Icon>
                    <div style="display:inline; margin-left:30px" >
                        <Icon type="md-home" />
                        <span style="margin-left:5px">首页</span>
                    </div>
                    <Dropdown style="float:right;margin-right:30px">
                        <a href="javascript:void(0)">
                            <Avatar icon="ios-person" size="large" style="background-color: #87d068;margin-right:5px"/>
                            <Icon type="ios-arrow-down"></Icon>
                        </a>
                        <DropdownMenu slot="list">
                            <DropdownItem>退出登录</DropdownItem>
                        </DropdownMenu>
                    </Dropdown>
                </Header>
                <Content :style="{margin: '2vh', background: '#fff', minHeight: '90vh'}">
                  <router-view/>
                </Content>
            </Layout>
        </Layout>
    </div>
</template>

<script>
// @ is an alias to /src
// import HelloWorld from '@/components/HelloWorld.vue'

export default {
  name: "home",
  data() {
    return {
      isCollapsed: false
    };
  },
  computed: {
    rotateIcon() {
      return ["menu-icon", this.isCollapsed ? "rotate-icon" : ""];
    },
    menuitemClasses() {
      return ["menu-item", this.isCollapsed ? "collapsed-menu" : ""];
    }
  },
  methods: {
    collapsedSider() {
      this.$refs.side1.toggleCollapse();
    }
  }
};
</script>
